package com.example.wifi_demo;

import android.util.Base64;

import java.io.UnsupportedEncodingException;

public class Base64Encoder {

    public static String encodeToString(String input) {
        // 使用Base64编码器对字符串进行编码
        try {
            byte[] data = input.getBytes("UTF-8");
            return Base64.encodeToString(data,Base64.DEFAULT);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
//        byte[] encodedBytes = Base64.encode(input.getBytes(), Base64.DEFAULT);
//        return new String(encodedBytes);
    }

}
